package unimelb.filesync.client.protocol;

import unimelb.filesync.common.misc.ProtocolContext;
import unimelb.filesync.common.network.NetworkConnection;
import unimelb.filesync.common.network.NetworkService;
import unimelb.filesync.common.protocol.IFileSyncPhase;
import unimelb.filesync.common.protocol.PrepareFileSync;

public class PrepareClientFileSync extends PrepareFileSync implements IFileSyncPhase {

    private final NetworkService networkService;

    public PrepareClientFileSync(ProtocolContext context) {
        super(context);
        this.networkService = new NetworkService();
    }

    @Override
    protected NetworkConnection createConnection() {
        final String serverHost = context.getObject(ProtocolContext.HOST);
        final Integer serverPort = context.getObject(ProtocolContext.PORT);
        return networkService.connectToServer(serverHost, serverPort);
    }

}
